var Koa = require("koa")
var path = require("path")
var wechat = require("./wechat/g")
var util = require("./libs/util")
var wechat_file = path.join(__dirname, "./wechat.txt")
var config = {
  wechat: {
    appID: "wx94129b7c2d0715dd",
    appSecret: "15f1b40362b301b2e2b0fb870a062bed",
    token: "xiaomuzhu123",
    getAccessToken: function () {
      return util.readFileAsync(wechat_file)
    },
    saveAccessToken: function (data) {
      data = JSON.stringify(data)
      return util.writeFileAsync(wechat_file, data)
    },
  },
}

var app = new Koa()
app.use(wechat(config.wechat))

app.listen(3000)
console.log("listen 1234")
